/**
 * Created:		2011-7-18
 * By:			eeorange
 * About:		zoj1067 - Color me less
 * Status:		Accept 188KB
 */

#include <cstdio>
#include <cstring> 
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

typedef int RGB[3];
RGB colors[16];

int main(){
	// read input
	for(int i=0; i<16; i++)
		cin >> colors[i][0] >> colors[i][1] >> colors[i][2];
	
	for(;;){
		RGB rgb;
		cin >> rgb[0] >> rgb[1] >> rgb[2];
		if(rgb[0] == -1 && rgb[1] == -1 && rgb[2] == -1) break;
		int min = 65535*3, idx;
		for(int i=0; i<16; i++){	// find the nearest color
			int d=0;
			for(int j=0; j<3; j++) d += (colors[i][j]-rgb[j])*(colors[i][j]-rgb[j]);
			if(min > d){ min = d; idx = i; }
		}
		printf("(%d,%d,%d) maps to (%d,%d,%d)\n", 
			rgb[0], rgb[1], rgb[2],
			colors[idx][0], colors[idx][1], colors[idx][2]);
	}
		
	return 0;
}

